{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "05532bbf",
   "metadata": {},
   "source": [
    "# IIR滤波器结构：直接Ⅱ型"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "81ab4c99",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbgAAAEoCAYAAAAqrOTwAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAgWElEQVR4nO3df5AcdZ3/8eeLTQJLqLhgIprVEFArpx5gdMtLDtSIYIRSLxXLg1POovSKnN75D7qaaKrwOJWcUe9KOYXUgXoUckQMe97x1fDLCHhA2LhABCsHX4Hw3YAkhDUCi4m77+8fPUMmk5nd7d7ZmZ3u16NqKjPdn+5+dz6z/Z7Ppz/drYjAzMwsb45odQBmZmZTwQnOzMxyyQnOzMxyyQnOzMxyyQnOzMxyyQnOrEUknSDp6FbHUY8kZZlnNl04wZlNkqSjJXWMU+ZeSSdVTb4CeFeDtj+jatqsivevkdSfcp3nAp8ao8inSmXMpi0nOCscSd+T9LdjTZP0RUnPSXpa0qCkT1fMu1nSPZLulHQn8CjwSPlzaV5f1WafB16Q9AZJV0q6HOgG1kq6XNK/SXrtWDGOMf0S4EFJO0vbfxG4RtI7JF0D/KH0QtIFkr43zv/PAmAVcPkYxa4APiHphLHWZdZKM8YvYlZYl0XEakkLga2SbomI+yPirMpCkn4KXBwR91SvoKoLcgbwIvAQScL5FdABvAYYBIazBBkRn5G0DXgdcCnwSER8SNIS4AAwCqS5o8MlwGciYv8Y2/yDpF7gH4ALssRtNtXcgjMbR0Q8BtwNLCpPk/RRSfdJug94O/C98mdJF1UsfjbwP8Bbgc3AK4HrgfcD3y7NOwv4l4jYlTY2SQslfbK0jjcDHwOOkfQJYG6G9R0JnBARvxyvbETcC5xUWsZs2nG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upy6PwW4KCK+DGwGziBl3bdlgiN5sOrG0vubgNNbF0pL3AucGRFvA2YC57Q4nmaoPsgvoyDfgYjYV/UA4cLUf40D/PkUpN4rSVoKHAvcTHHq/ucRcbekd5C04paTsu7bNcHNBsqP494LHN/CWFrhgYh4svS+H8j1r1ioeZAv8negcPVfcYB/goLVu6TjgG8BH6NgdS9JJD9snwWClHXfrgnuOaD8MLdjaN/9yOpqSadK6gBWAPe3OJ5WKPJ3oFD1X3WAL1S9S5oF/BBYExGPU7C6j8TfAQ8Af07Kum/XL8c2DjZPTwUea10oLXEJcDVwH3BXRNzS2nBaosjfgcLUf40DfNHq/ePAW4AvSNoCPEhx6v5zkj5a+tgFrCNl3bflhd6S5gB3ALcCZwNLqrqvLKckbYmIZf4OFIOkTwBf4WBL5bvARbjec680sGwjcCTwK2ANcDsp6r4tExy8tPNnAbdHxFOtjseaz9+BYnK9F1faum/bBGdmZjaWdj0HZ2ZmNiYnODMzyyUnODMzyyUnODMzyyUnODMzy6X/D+MoCNkczsKPAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "#libraries\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy import signal\n",
    "\n",
    "#parameters of defference equation\n",
    "b = np.array([[1,0,0,0,0],[1,-3,11,27,18]]) #numerator\n",
    "a = np.array([[16,12,2,-4,-2],[1,0,0,0,0]]) #denominator\n",
    "\n",
    "#input signal\n",
    "M = a.shape[0];N = 30\n",
    "delta = signal.unit_impulse(N) #unit sample signal\n",
    "y = np.ones(N) #unit step signal\n",
    "\n",
    "#IIR dirIIfilter\n",
    "z1 = np.zeros((M+1,N));z2 = np.zeros((M+1,N));\n",
    "z1[0,:] = delta;z2[0,:] = y; \n",
    "for i in range(M): #循环滤波，计算最终结果\n",
    "    zi = signal.lfilter_zi(b[i,:],a[i,:])*0 #zero initial condition\n",
    "    z1[i+1,:],_ = signal.lfilter(b[i,:],a[i,:],z1[i,:],zi=zi);\n",
    "    z2[i+1,:],_ = signal.lfilter(b[i,:],a[i,:],z2[i,:],zi=zi);\n",
    "\n",
    "#plot\n",
    "fig,axs = plt.subplots(2,1,constrained_layout=True)\n",
    "axs[0].stem(z1[M,:],basefmt=\"\");axs[1].stem(z2[M,:],basefmt=\"\")\n",
    "plt.rcParams['font.sans-serif']=['SimHei'] #用来正常显示中文标签\n",
    "axs[0].set_title('IIR直接II型h(n)')\n",
    "axs[1].set_title('IIR直接II型y(n)')\n",
    "plt.show();fig.savefig('./iir_dir_II_sequence.png',dpi=500)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "789cac5f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
